<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/messages.jsp"%>
<%@ include file="/commons/commonEdit.jsp" %>
<%@ include file="/commons/validation.jsp" %>
<%@ include file="/commons/dateTime.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>物品托管</title>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script type="text/javascript">
function choiceHouse(){
	var url = "${ctx}/customer_chooseSingleHouseAction.do?method=chooseBuildingMain";
	top.windowOpen(url, "choiceHouse", "", 500, 800);
}
function setHouseInfo(houseId,houseNum){
		document.getElementById("houseId").value = houseId;
		document.getElementById("houseNumber").value = houseNum;
		$('houseNumber').fireEvent("onblur");
}
function addThingEntrust(){
	var isTrue=$('thingEntrustForm').fireEvent("onSubmit") ;
    if(isTrue){
    	document.getElementById('sumitok').disabled = true;
        var param = Form.serialize('thingEntrustForm');
        var url = null;
		if('${flag}' == "add")
		   url = "${ctx}/thing_thingEntrustAction.do?method=addThingEntrust";
		else
		   url = "${ctx}/thing_thingEntrustAction.do?method=editThingEntrust";
       new Ajax.Request(url,{method: 'post',parameters :param ,onSuccess : showResult});
	}
}
function ajaxSearchHouseInfo(){
	var url = "${ctx}/thing_thingEntrustAction.do?method=queryOwnerHouseInfo";
	var houseId = $F('houseId');
	if(houseId == "")
		return;
	var param = "houseId="+houseId;
	new Ajax.Request(url,{method: 'post', parameters: param, onComplete: showResponse});
}
function showResponse(result){
	var obj = eval("("+result.responseText+")");
	if("false" == result.responseText){
		Alert("没有业主请重新选择!");
		$('houseNumber').value="";
		$('houseId').value="";
		return false;
	}
	$('coalitionHouseNumber').innerHTML = obj.coalitionHouseNumber;
	$('owners').innerHTML = obj.ownerName;
}
function openChooseAssessor(){
		// var url ="${ctx }/common_employeeQuery.do?method=initMain&parentFrameId=houseChoose&methodName=setHandover";

	 	 var url = "${ctx}/common_employeeQuery.do?method=initSelectPsrsonMain";
	  	 url += "&frameName=houseChoose";
	  	 url += "&callBack=setHandover";
	  	 url += "&multiple=false";
		 top.windowOpen(url, "selectPerson", "选人", 530, 700,true,"selectPerson");
}
function setHandover(info){
		var onePerson= new Array();
	    onePerson=info.split(";");
	    for (i=0;i<onePerson.length ;i++ )
	    {
	     var oneAttribute= new Array();
	     oneAttribute=onePerson[i].split(",");
		 $('accepterId').value=oneAttribute[0];
		 $('accepterName').value=oneAttribute[1];
		 $('accepterName').fireEvent("onblur");
		}
}
function showResult(response){
	if(response.responseText == "true"){
		var obj = findFrame('thingEntrustBaseMain');
		obj.reloadThingEntrust();
		windowClose();
    }else{
		document.getElementById('sumitok').disabled = false;
    	ajaxSubmitException(response.responseText);
    }

}
</script>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle" /> <span class="window_head_intext">物品托管</span> </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td colspan="2" class="content"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="aux_outtable_color">
            <form action="" method="post" name="thingEntrustForm" class="required-validate">
            <input type="hidden" name="houseId" value="${thingEntrust.houseId }">
            <input type="hidden" name="keyword" value="${thingEntrust.keyword }">
            <input type="hidden" name="accepterId" value="${thingEntrust.accepterId }">
	        <table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
                <tr>
                    <td valign="top" class="aux_intable_td1">房 号：</td>
                    <td valign="top" class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td></td>
                          <td></td>
                        </tr>
                        <tr>
                          <td><input name="houseNumber" readonly="readonly" type="text" class="required" size="16" onblur="ajaxSearchHouseInfo()" value="${thingEntrust.houseNumber }"/></td>
                          <td width="4">&nbsp;</td>
                          <td><a href="#"  onClick="choiceHouse();" onFocus="this.blur()" ><img src="${ctx}/images/ico_houesno.GIF" alt="请点选查找房号" border="0" /></a></td>
                        </tr>
                    </table></td>
               </tr>
			   <tr>
				  <td valign="top" class="aux_intable_td1">业 主： </td>
				  <td valign="middle" class="aux_intable_td2" id="owners">${owners }</td>
			   </tr>
			   <tr>
				  <td valign="top" class="aux_intable_td1">管理房号： </td>
				  <td valign="middle" class="aux_intable_td2" id="coalitionHouseNumber">${thingEntrust.coalitionHouseNumber }</td>
	           </tr>
			   <tr >
	             <td class="aux_intable_td1">托管人：</td>
	             <td class="aux_intable_require"><input name="entrustMan" type="text" class="required validate-char" value="${thingEntrust.entrustMan }" size="16" maxlength="36"/></td>
	           </tr>
			   <tr >
			     <td class="aux_intable_td1">托管物品：</td>
			     <td class="aux_intable_require"><input name="entrustItem" type="text" class="required validate-char" value="${thingEntrust.entrustItem }" size="16" maxlength="100"/></td>
			     </tr>
	           <tr >
	             <td class="aux_intable_td1">接手人：</td>
	             <td class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
	               <tr>
	                 <td><input name="accepterName" type="text" class="inputtext" readonly="readonly" value="${thingEntrust.accepterName }" size="16" /></td>
	                 <td width="4">&nbsp;</td>
	                 <td><a href="#"  onClick="openChooseAssessor();" onFocus="this.blur()"><img src="${ctx}/images/ico_cz.gif" width="16" height="16" border="0" /></a></td>
	               </tr>
	             </table></td>
	           </tr>
		       <tr >
		           <td class="aux_intable_td1">接受日期：</td>
		           <td class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
		               <tr>
		                  <td><input name="acceptDate" type="text" class="required validate-date-yyyy-MM-dd " value="<fmt:formatDate value='${thingEntrust.acceptDate }' pattern='yyyy-MM-dd'/>" size="16" maxlength="10" afterInsert="dateAfter"/></td>
		                  <td width="4">&nbsp;</td>
		                  <td><img name="acceptDateButton" src="${ctx}/images/ico_clock.gif" width="20" height="20" /><span id="dateAfter"></span></td>
		                </tr>
		            </table></td>
		       </tr>
	           <tr id="tr03">
	            <td valign="top" class="aux_intable_td1">托管原因：</td>
	            <td valign="top" class="aux_intable_require_more"><textarea name="entrustReason" cols="29" rows="2" class="required max-length-200">${thingEntrust.entrustReason }</textarea></td>
	           </tr>
		</table>
		</form>
	 </td>
	</tr>
	</table></td></tr>
	<tr>
	    <td class="window_footer">&nbsp;</td>
	    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
	        <tr>
	          <td><table id="sumitok" border="0" cellpadding="0" cellspacing="0" onclick="addThingEntrust()">
	            <tr>
	              <td class="buttonOffLeft" id="btn1_21"></td>
	              <td class="buttonOffMiddle" id="btn1_22"  onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onblur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 保 存</td>
	              <td class="buttonOffRight" id="btn1_23"></td>
	            </tr>
	        </table></td>
	          <td class="btn_between_space"></td>
	          <td><table border="0" cellpadding="0" cellspacing="0">
	              <tr>
	                <td class="buttonOffLeft" id="btn1_31"></td>
	                <td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onBlur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 关 闭</td>
	                <td class="buttonOffRight" id="btn1_33"></td>
	              </tr>
	          </table></td>
	        </tr>
           </table></td>
    </tr>
</table>
<script type="text/javascript">
Calendar.setup(
              {
	              inputField : "acceptDate", // ID of the input field
	              ifFormat : "%Y-%m-%d", // the date format
	              button : "acceptDateButton", // ID of the button
	              align          :    "Tl",           // alignment (defaults to "Bl")
			      singleClick    :    true
              }
              );
</script>
</body>
</html>